

package coms.action;

import java.util.Map;

import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
//import coms.ejb.sessionbean.COMSManagerBeanRemote;
import coms.ejb.sessionbean.*;
import coms.datatransfer.*;




public class ConferenceUserRegistrationAction extends ActionSupport  {
	
	
	public String execute(){
	
		try{
		HttpServletRequest request = (HttpServletRequest) ActionContext.getContext().get(ServletActionContext.HTTP_REQUEST);
		Map<String,Object> session = ActionContext.getContext().getSession();
		
		ConferenceBeanRemote bean=lookupRemoteBean();	
		
		if(request.getParameter("conferenceItemID")!=null)
		{
			
			session.put("conferenceItemID",request.getParameter("conferenceItemID"));
		}
		
		
		bean.registerParticipant(Integer.parseInt(request.getParameter("conferenceItemID").toString()),Integer.parseInt(session.get("userID").toString()));
		
		return "SUCCESS";
		} catch (Exception e){
			return "exception";
		}
	
	}
	
	private ConferenceBeanRemote lookupRemoteBean() throws NamingException{
		InitialContext ctx = new InitialContext();
		
		System.out.println("In Look up method");
		return (ConferenceBeanRemote) ctx.lookup("java:app/coms-ejb/ConferenceBean!coms.ejb.sessionbean.ConferenceBeanRemote");
	
	
	}

	

}
